// 20-职位分享
// 1-人才分享
// 25-简历转发
// 30-赞了文章
// 31-赞了评论
// 11、2-社群文章分享
// 10-社群分享
// 4-图片分享
// 5-语音消息
// 6-约谈消息
// 52=委托服务
// 60-交换电话
// 70-面试邀请
// 80-DISC测评
// 90-附件简历
// 100-文件
// 111-个人简历
// 101-卡片服务
// 102-服务端主动推送查看总结卡片
// 103-服务端主动推送邀请用户评论的卡片
// 104-用户确认或者取消服务的提示类型
// 105-顾问发送的结束服务的卡片
// 106-顾问发送的评价服务的卡片
// 201-职途2.0进度卡片
// 202-职途2.0结果卡片
// 203-职途常见问题卡片
// 204-职途2.0评价卡片
// 205-职途2.0权益营销页卡片
// 206-职途2.0体验咨询过期卡片
// 207-职途2.0时间还未到卡片
// 其余的统一发送—[发送了一条新的聊天类型，请您及时升级一览职业app进行查看]

-(instancetype)initWithShareDictionary:(NSDictionary *)dic
{
    NSDictionary *dict = dic;
    self = [super init];
    if (self) {
        self.send_uid = [dic objectForKey:@"send_uid"];
        self.receive_uid = [dic objectForKey:@"receive_uid"];
        self.isSend = dic[@"is_send"];
        self.flag = [dic objectForKey:@"flag"];
        self.personIName = dic[@"person_iname"];
        self.personPic = dic[@"person_pic"];
        self.content = dic[@"content"];
        
        NSString *idateStr = [NSString stringWithFormat:@"%@",dic[@"idate"]];
        NSDate *dateTime = [MyCommon getDate:[MyCommon getDateWithMsecTime:idateStr]];
        NSString *dateStr = [MyCommon compareCurrentTimePrestige:dateTime currentString:idateStr];
        self.date = dateStr;
        self.idate = idateStr;
        
        NSDictionary *companyDic = dict[@"company_info"];
        if ([companyDic isKindOfClass:[NSDictionary class]]) {
            self.companyId = companyDic[@"id"];
            self.companyName = companyDic[@"cname"];
            self.companyLogo = companyDic[@"cname"];
        }
        
        NSDictionary *shareInfo = dict[@"_share_info"];
        
        if (!shareInfo || ![shareInfo isKindOfClass:[NSDictionary class]])
        {
            shareInfo = dict[@"share"];
        }
        id type = shareInfo[@"type"];
        NSString *shareType = type;
        if ([type isKindOfClass:[NSNumber class]]) {
            shareType = [type stringValue];
        }
        NSDictionary *shareDict = shareInfo[@"slave"];
        if ([shareType isEqualToString:@"20"]) {    // 职位分享
            self.messageType = MessageTypeShareJob;
            JobSearch_DataModal *jobModel = [[JobSearch_DataModal alloc]init];
            jobModel.zwID_ = shareDict[@"position_id"];
            jobModel.zwName_ = shareDict[@"position_name"];
            jobModel.salary_  = shareDict[@"position_salary"];
            jobModel.regionName_ = shareDict[@"position_regionname"];
            jobModel.edu_ = shareDict[@"position_edus"];
            jobModel.gznum_ = shareDict[@"position_gznum"];
            jobModel.companyName_ = shareDict[@"position_company"];
            jobModel.companyID_ = shareDict[@"position_company_id"];
            jobModel.companyLogo_ = shareDict[@"position_logo"];
            jobModel.sa_person_id = shareDict[@"sa_person_id"];
            
            if ([[shareDict objectForKey:@"firstSend"] isEqualToString:@"1"]) {
                self.messageType = MessageTypeChatRelatedPosition;
                jobModel.tips = [NSString stringWithFormat:@"正在沟通的职位：%@",jobModel.zwName_];
            }
            if ([[shareDict objectForKey:@"position_change"] isEqualToString:@"1"]) {
                self.messageType = MessageTypeChatRelatedPosition;
                jobModel.tips = [NSString stringWithFormat:@"%@更换了正在沟通的职位",[self.isSend isEqualToString:@"1"] ? @"您" : @"对方"];
            }
            
            self.positionTips = shareDict[@"tishi"];
            self.otherModel = jobModel;
        } else if ([shareType isEqualToString:@"1"]) {      // 人才分享
            self.messageType = MessageTypeShareUser;
            User_DataModal *userModel = [[User_DataModal alloc]init];
            userModel.img_ = shareDict[@"person_pic"];
            userModel.uname_= shareDict[@"person_iname"];
            userModel.userId_ = shareDict[@"person_id"];
            userModel.zym_ = shareDict[@"person_zw"];
            self.otherModel = userModel;
        } else if ([shareType isEqualToString:@"25"]) {     // 简历转发
            self.messageType = MessageTypeShareReusme;
            ShareMessageModal *userModel = [[ShareMessageModal alloc]init];
            userModel.personId = shareDict[@"person_id"];
            userModel.personName = shareDict[@"person_iname"];
            userModel.person_pic = shareDict[@"person_pic"];
            userModel.person_zw = shareDict[@"person_zw"];
            userModel.person_gznum = shareDict[@"person_gznum"];
            userModel.person_edu = shareDict[@"person_edu"];
            userModel.person_region = shareDict[@"person_shi"];
            userModel.person_job = shareDict[@"person_job"];
            userModel.person_company = shareDict[@"person_company"];
            userModel.person_region = shareDict[@"person_regionname"];
            self.positionTips = shareDict[@"tishi"];
            
            userModel.personName = [MyCommon translateHTML:userModel.personName];
            userModel.person_zw = [MyCommon translateHTML:userModel.person_zw];
            userModel.person_gznum = [MyCommon translateHTML:userModel.person_gznum];
            userModel.person_edu = [MyCommon translateHTML:userModel.person_edu];
            self.otherModel = userModel;
        } else if ([shareType isEqualToString:@"30"]) {     // 赞了文章
            self.messageType = MessageTypeLikeArticle;
            Article_DataModal *modal = [[Article_DataModal alloc] init];
            modal.id_ = shareDict[@"article_id"];
            modal.title_ = shareDict[@"article_title"];
            modal.thum_ = shareDict[@"article_thumb"];
            modal.summary_ = shareDict[@"article_summary"];
            modal.xw_type_ = shareDict[@"article_type"];
            self.otherModel = modal;
        } else if ([shareType isEqualToString:@"31"]) {   // 赞了评论
            self.messageType = MessageTypeLikeComment;
            Article_DataModal *modal = [[Article_DataModal alloc] init];
            modal.personID_ = shareDict[@"comment_id"];
            modal.content_ = shareDict[@"comment_content"];
            modal.id_ = shareDict[@"article_id"];
            modal.title_ = shareDict[@"article_title"];
            modal.xw_type_ = shareDict[@"article_type"];
            self.otherModel = modal;
        } else if ([shareType isEqualToString:@"11"] || [shareType isEqualToString:@"2"]) {     // 社群文章分享
            self.messageType = MessageTypeGroupArticle;
            Article_DataModal *modal = [[Article_DataModal alloc] init];
            if ([shareDict isKindOfClass:[NSDictionary class]]) {
                modal.id_ = shareDict[@"article_id"];
                modal.title_ = shareDict[@"article_title"];
                modal.thum_ = shareDict[@"article_thumb"];
                modal.summary_ = shareDict[@"article_summary"];
                modal.title_ = [MyCommon translateHTML:modal.title_];
            }
            self.otherModel = modal;
        } else if ([shareType isEqualToString:@"10"]) {     // 社群分享
            self.messageType = MessageTypeGroup;
            Groups_DataModal *modal = [[Groups_DataModal alloc] init];
            modal.id_ = shareDict[@"group_id"];
            modal.name_ = shareDict[@"group_name"];
            modal.pic_ = shareDict[@"group_pic"];
            modal.personCnt_ = [shareDict[@"group_person_cnt"] integerValue];
            modal.articleCnt_ = [shareDict[@"group_article_cnt"] integerValue];
            modal.charge = shareDict[@"charge"];
            modal.name_ = [MyCommon translateHTML:modal.name_];
            self.otherModel = modal;
        } else if ([shareType isEqualToString:@"4"]) {      // 图片分享
            self.messageType = MessageTypeImage;
            self.imageUrl_ = shareDict[@"path"];
        } else if ([shareType isEqualToString:@"5"]) {      // 语音消息
            //语音消息封装
            self.messageType = MessageTypeVoice;
            NSString *tempStr = shareDict[@"path"];;
            self.imageUrl_ = tempStr;
            NSArray *voiceArr = [tempStr componentsSeparatedByString:@"#"];
            self.voiceTime = [voiceArr lastObject];
            if ([voiceArr count] >=2) {
                self.voiceTime = [voiceArr lastObject];
            }
            tempStr = [voiceArr firstObject];
            self.content = tempStr;
        } else if ([shareType isEqualToString:@"6"]) {    // 约谈消息
            self.messageType = MessageTypeQuestioning;
            
            self.aspDiscuss = [[ELAspectantDiscuss_Modal alloc] init];
            self.aspDiscuss.recordId = shareDict[@"record_id"];
            
            if (self.aspDiscuss.recordId == nil || [self.aspDiscuss.recordId isEqualToString:@""]) {
                
                self.questionTitle = shareDict[@"title"];
                self.questionMobile = shareDict[@"mobile"];
                self.questionContent = shareDict[@"question"];
                self.introContent = shareDict[@"intro"];
                self.questionTips = shareDict[@"tips"];
            } else {
                self.aspDiscuss.course_title = shareDict[@"course_title"];
                self.aspDiscuss.course_price = shareDict[@"course_price"];
                self.aspDiscuss.dataTime = shareDict[@"idatetime"];
                self.aspDiscuss.YTZ_id = shareDict[@"person_id"];
                self.aspDiscuss.BYTZ_Id = shareDict[@"yuetan_person_id"];
                
                if ([[Manager getUserInfo].userId_ isEqualToString:self.aspDiscuss.YTZ_id]) {
                    self.aspDiscuss.user_personId = [Manager getUserInfo].userId_;
                    self.aspDiscuss.user_name = [Manager getUserInfo].name_;
                    self.aspDiscuss.user_pic = [Manager getUserInfo].img_;
                    self.aspDiscuss.user_zw = [Manager getUserInfo].job_;
                    
                    self.aspDiscuss.dis_personId = shareDict[@"yuetan_person_detail"][@"personId"];
                    self.aspDiscuss.dis_personName = shareDict[@"yuetan_person_detail"][@"person_iname"];;
                    self.aspDiscuss.dis_pic = shareDict[@"yuetan_person_detail"][@"person_pic"];
                    self.aspDiscuss.dis_zw = shareDict[@"yuetan_person_detail"][@"person_zw"];
                } else {
                    self.aspDiscuss.user_personId = shareDict[@"person_detail"][@"personId"];
                    self.aspDiscuss.user_name = shareDict[@"person_detail"][@"person_iname"];
                    self.aspDiscuss.user_pic = shareDict[@"person_detail"][@"person_pic"];
                    self.aspDiscuss.user_zw = shareDict[@"person_detail"][@"person_zw"];
                    
                    self.aspDiscuss.dis_personId = [Manager getUserInfo].userId_;
                    self.aspDiscuss.dis_personName = [Manager getUserInfo].name_;
                    self.aspDiscuss.dis_pic = [Manager getUserInfo].img_;
                    self.aspDiscuss.dis_zw = [Manager getUserInfo].job_;
                }
            }
        } else if ([shareType isEqualToString:@"52"]) {     // 委托服务
            self.messageType = MessageTypeWeiTuo;
            self.msgId = dict[@"pmsg_id"];
            self.isSend = dict[@"is_send"];
//            self.isHaveRead = [dic objectForKey:@"isHaveRead"];
            self.flag = [dic objectForKey:@"flag"];
            self.personIName = dict[@"person_iname"];
            self.personPic = dict[@"person_pic"];
            self.content = dict[@"content"];
            //            self.date = dict[@"idate"];
            //            self.idate = [dict[@"idate"] isKindOfClass:[NSString class]] ? dict[@"idate"] : [NSString stringWithFormat:@"%@",dict[@"idate"]];
            NSString *idateStr = [NSString stringWithFormat:@"%@",dic[@"idate"]];
            NSDate *dateTime = [MyCommon getDate:[MyCommon getDateWithMsecTime:idateStr]];
            NSString *dateStr = [MyCommon compareCurrentTimePrestige:dateTime currentString:idateStr];
            self.date = dateStr;
            self.idate = idateStr;
            
            self.slave_title = shareDict[@"title"];
            self.slave_price = shareDict[@"price"];
            self.slave_content = shareDict[@"content"];
            self.slave_target = shareDict[@"target"];
            self.action = shareDict[@"action"];
            self.terget_title = shareDict[@"terget_title"];
            self.be_user_id = shareDict[@"be_user_id"];
            self.be_person_id = shareDict[@"be_person_id"];
            self.person_id = shareDict[@"person_id"];
            self.pic = shareDict[@"pic"];
            self.record_status = shareDict[@"record_status"];
            self.record_desc = shareDict[@"record_desc"];
        } else if ([shareType isEqualToString:@"60"]) {     // 交换电话
            self.messageType = MessageTypeExchangePhoneNum;
            ELMessageExchangePhoneNumModel *exchangePhoneNumModel = [ELMessageExchangePhoneNumModel mj_objectWithKeyValues:shareDict];
            self.otherModel = exchangePhoneNumModel;
        } else if ([shareType isEqualToString:@"70"]) {     // 面试邀请
            self.messageType = MessageTypeInterviewInvitation;
            ELMessageInvitationInfoModel *invitationModel = [ELMessageInvitationInfoModel mj_objectWithKeyValues:shareDict];
            self.otherModel = invitationModel;
            self.interview_invitation_state = invitationModel.state;
        } else if ([shareType isEqualToString:@"80"]) {     // DISC测评
            self.messageType = MessageTypeDSIC;
            ELMessageDISCModel *inviteDISCModel = [ELMessageDISCModel mj_objectWithKeyValues:shareDict];
            inviteDISCModel.shareType = shareType;
            inviteDISCModel.shareContent = self.content;
            self.otherModel = inviteDISCModel;
            
        } else {
            NSDictionary *newMsgTypePlistFileDic = [[NSDictionary alloc] initWithContentsOfFile:IMNewMessageTypeDatasFilePath];
            NSDictionary *newMsgTypeTipsDic = [newMsgTypePlistFileDic objectForKey:@"lower_version_tips"];
            NSString *tipsStr = nil;
            if (DictIsNotEmpty(newMsgTypeTipsDic)) {
                tipsStr = [newMsgTypeTipsDic objectForKey:shareType];
                if (StringIsEmpty(tipsStr)) {
                    tipsStr = [newMsgTypeTipsDic objectForKey:@"default_tips"];
                }
            }

            if (StringIsEmpty(tipsStr)) {
                tipsStr = @"[发送了一条新的聊天类型，请您及时升级一览职业app进行查看]";
            }
            
            NSMutableDictionary *msgDic = [[NSMutableDictionary alloc] initWithDictionary:dic];
            [msgDic setObject:tipsStr forKey:@"content"];
            return [self initWithTextDictionary:msgDic];
        }
        
        self.title = [MyCommon translateHTML:self.title];
        self.content = [MyCommon translateHTML:self.content];
        
    }
    return self;
}

// 后台返回数据
// DISC
// {
//   "is_send" : "1",
//   "content" : "DISC测评",
//   "_share_info" : {
//     "type" : "80",
//     "title" : "DISC测评",
//     "slave" : {
//       "receive_uid" : "23963641",
//       "send_uname" : "凌峰",
//       "isDISCResult" : "2",
//       "send_uid" : "23150821"
//     }
//   },
//   "idate" : "2022-03-08 15:01:24",
//   "person_iname" : "凌峰",
//   "company_info" : null,
//   "type" : "3",
//   "pmsg_id" : "jg13247067504",
//   "person_pic" : "https:\/\/img106.job1001.com\/upload\/adminnew\/2022-02-14\/1644818789-G6YWSMU.jpg"
// }

// 图片
// {
//   "is_send" : "1",
//   "content" : "[图片]",
//   "receive_uid" : "23963641",
//   "idate" : "1646725730022",
//   "person_iname" : "凌峰",
//   "send_uid" : "23150821",
//   "share" : {
//     "type" : "4",
//     "slave" : {
//       "path" : "http:\/\/img105.job1001.com\/upload\/album\/2022-03-08\/1646725729-JVDW6L5.jpg#http:\/\/img105.job1001.com\/upload\/album\/2022-03-08\/1646725729-JVDW6L5_670_625.jpg"
//     }
//   },
//   "person_pic" : "https:\/\/img106.job1001.com\/upload\/adminnew\/2022-02-14\/1644818789-G6YWSMU.jpg"
// }
